package com.rabbiter.oes.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.rabbiter.oes.entity.Major;
import com.rabbiter.oes.vo.MajorVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

@Mapper
public interface MajorMapper extends BaseMapper<Major> {

    IPage<MajorVO> findPage(Page page, @Param("name") String name);

    default IPage<Major>  findAll(Page page) {
        return selectPage(page, Wrappers.lambdaQuery());
    }

    default Long findCountByName (String name) {
        LambdaQueryWrapper<Major> wrapper =new LambdaQueryWrapper<>();
        wrapper.apply("name='" + name.concat("'"));
        return selectCount(wrapper);
    }

}
